package com.njbw.tool;

import org.apache.commons.lang3.StringUtils;

/**
 * 字母转换工具类
 */
public class LetterUtil {

    /**
     * 字母转数字
     */
    public static long letterToNumber(String letter) {
        int length = letter.length();
        long number = 0;
        for (int i = 0; i < length; i++) {
            char ch = letter.charAt(length - i - 1);
            int num = ch - 'A' + 1;
            number += num;
        }
        return number;
    }

    /**
     * 字符串拼接
     */
    public static String assembleHandler(char splitChar, String... args) {
        return StringUtils.join(args, splitChar);
    }

    public static void main(String[] args) {
        System.out.println(letterToNumber("abc"));
        System.out.println(((int) 'a')); // 97
        System.out.println(((int) 'A')); // 65
    }
}
